<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>美兰数据文化馆与图书馆</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/css/public.css" media="all">
    <link rel="shortcut icon" href="<%=request.getContextPath()%>/huazhi/images/favicon.ico"/>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-tab layui-tab-card">
                <ul class="layui-tab-title">
                    <li class="layui-this" id="one">基本信息</li>
                    <li id="two">详细信息</li>
                    <li id="three">维护项目</li>
                    <li id="four">扩展信息</li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show" id="onecontent">
                        <table id="basic" lay-filter="basicList"></table>
                        <div id="basiclaypage"></div>
                    </div>
                    <div class="layui-tab-item" id="twocontent">
                        <div class="layui-tab-item layui-show">
                            <table id="detailed" lay-filter="detailedList"></table>
                            <div id="detailedlaypage"></div>
                        </div>
                    </div>
                    <div class="layui-tab-item" id="threecontent">
                        <div class="layui-tab-item layui-show">
                            <table id="maintain" lay-filter="maintainList"></table>
                            <div id="maintainlaypage"></div>
                        </div>
                    </div>
                    <div class="layui-tab-item" id="fourcontent">
                        <div class="layui-tab-item layui-show">
                            <table id="extend" lay-filter="extendList"></table>
                            <div id="extendlaypage"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<%--基本信息按钮--%>
<script type="text/html" id="basicDemo">
    <shiro:hasPermission name="sys:att:add">
        <div class="layui-inline" lay-event="add" title="添加">
            <i class="layui-icon layui-icon-add-1"></i>
        </div>
    </shiro:hasPermission>
    <%--    <div class="layui-inline" lay-event="update" title="修改">--%>
    <%--    <i class="layui-icon layui-icon-edit"></i>--%>
    <%--    </div>--%>
</script>
<%--详细信息按钮--%>
<script type="text/html" id="detailedDemo">
    <shiro:hasPermission name="sys:att:add">
        <div class="layui-inline" lay-event="add" title="添加">
            <i class="layui-icon layui-icon-add-1"></i>
        </div>
    </shiro:hasPermission>
    <%--    <div class="layui-inline" lay-event="update" title="修改">--%>
    <%--    <i class="layui-icon layui-icon-edit"></i>--%>
    <%--    </div>--%>
</script>
<%--维护信息按钮--%>
<script type="text/html" id="maintainDemo">
    <shiro:hasPermission name="sys:att:add">
        <div class="layui-inline" lay-event="add" title="添加">
            <i class="layui-icon layui-icon-add-1"></i>
        </div>
    </shiro:hasPermission>
    <%--    <div class="layui-inline" lay-event="update" title="修改">--%>
    <%--    <i class="layui-icon layui-icon-edit"></i>--%>
    <%--    </div>--%>
</script>
<%--扩展信息按钮--%>
<script type="text/html" id="extendDemo">
    <shiro:hasPermission name="sys:att:add">
        <div class="layui-inline" lay-event="add" title="添加">
            <i class="layui-icon layui-icon-add-1"></i>
        </div>
    </shiro:hasPermission>
    <%--    <div class="layui-inline" lay-event="update" title="修改">--%>
    <%--        <i class="layui-icon layui-icon-edit"></i>--%>
    <%--    </div>--%>
</script>
<script type="text/html" id="basictable">
    <shiro:hasPermission name="sys:att:update">
        {{# if(d.change== 'yes'){}}
        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="update">修改</a>
        {{# } else {}}
        <a class="layui-btn layui-btn-disabled layui-btn-xs">修改</a>
        {{# }}}
    </shiro:hasPermission>
    <shiro:hasPermission name="sys:att:del">
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </shiro:hasPermission>
</script>
<script type="text/html" id="detailedtable">
    <shiro:hasPermission name="sys:att:update">
        {{# if(d.change== 'yes'){}}
        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="update">修改</a>
        {{# } else {}}
        <a class="layui-btn layui-btn-disabled layui-btn-xs">修改</a>
        {{# }}}
    </shiro:hasPermission>
    <shiro:hasPermission name="sys:att:del">
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </shiro:hasPermission>
</script>
<script type="text/html" id="maintaintable">
    <shiro:hasPermission name="sys:att:update">
        {{# if(d.change== 'yes'){}}
        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="update">修改</a>
        {{# } else {}}
        <a class="layui-btn layui-btn-disabled layui-btn-xs">修改</a>
        {{# }}}
    </shiro:hasPermission>
    <shiro:hasPermission name="sys:att:del">
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </shiro:hasPermission>
</script>
<script type="text/html" id="extendtable">
    <shiro:hasPermission name="sys:att:update">
        {{# if(d.change== 'yes'){}}
        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="update">修改</a>
        {{# } else {}}
        <a class="layui-btn layui-btn-disabled layui-btn-xs">修改</a>
        {{# }}}
    </shiro:hasPermission>
    <shiro:hasPermission name="sys:att:del">
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </shiro:hasPermission>
</script>
<script type="text/html" id="statebasic">
    {{#  if(d.change== 'yes'){}}
    <input type="checkbox" name="state" value="{{d.id}}" lay-skin="switch" lay-text="是|否" lay-filter="statebasic" {{
           d.state==1?'checked':'' }}>
    {{#  } else {}}
    <input type="checkbox" name="state" value="{{d.id}}" lay-skin="switch" disabled lay-text="是|否"
           lay-filter="statebasic" {{ d.state==1?'checked':'' }}>
    {{#  } }}
</script>
<script type="text/html" id="isValidatebasic">
    {{#  if(d.change== 'yes'){}}
    {{#  if(d.type== 'textarea'||d.type== 'radio'||d.type=='checkbox'||d.type=='selects'){}}
    <input type="checkbox" name="isValidate" value="{{d.id}}" lay-skin="switch" lay-text="是|否" disabled
           lay-filter="isValidatebasic" {{ d.isValidate=="yes"?'checked':'' }}>
    {{#  } else {}}
    <input type="checkbox" name="isValidate" value="{{d.id}}" lay-skin="switch" lay-text="是|否"
           lay-filter="isValidatebasic" {{ d.isValidate=="yes"?'checked':'' }}>
    {{#  } }}
    {{#  } else {}}
    <input type="checkbox" name="isValidate" value="{{d.id}}" lay-skin="switch" disabled lay-text="是|否"
           lay-filter="isValidatebasic" {{ d.isValidate=="yes"?'checked':'' }}>
    {{#  } }}
</script>
<script type="text/html" id="statedetailed">
    {{#  if(d.change== 'yes'){}}
    <input type="checkbox" name="state" value="{{d.id}}" lay-skin="switch" lay-text="是|否" lay-filter="statebasic" {{
           d.state==1?'checked':'' }}>
    {{#  } else {}}
    <input type="checkbox" name="state" value="{{d.id}}" lay-skin="switch" disabled lay-text="是|否"
           lay-filter="statebasic" {{ d.state==1?'checked':'' }}>
    {{#  } }}
</script>
<script type="text/html" id="isValidatedetailed">
    {{#  if(d.change== 'yes'){}}
    {{#  if(d.type== 'textarea'||d.type== 'radio'||d.type=='checkbox'||d.type=='selects'){}}
    <input type="checkbox" name="isValidate" value="{{d.id}}" lay-skin="switch" lay-text="是|否" disabled
           lay-filter="isValidatebasic" {{ d.isValidate=="yes"?'checked':'' }}>
    {{#  } else {}}
    <input type="checkbox" name="isValidate" value="{{d.id}}" lay-skin="switch" lay-text="是|否"
           lay-filter="isValidatebasic" {{ d.isValidate=="yes"?'checked':'' }}>
    {{#  } }}
    {{#  } else {}}
    <input type="checkbox" name="isValidate" value="{{d.id}}" lay-skin="switch" disabled lay-text="是|否"
           lay-filter="isValidatebasic" {{ d.isValidate=="yes"?'checked':'' }}>
    {{#  } }}
</script>
<script type="text/html" id="statemaintain">
    {{#  if(d.change== 'yes'){}}
    <input type="checkbox" name="state" value="{{d.id}}" lay-skin="switch" lay-text="是|否" lay-filter="statebasic" {{
           d.state==1?'checked':'' }}>
    {{#  } else {}}
    <input type="checkbox" name="state" value="{{d.id}}" lay-skin="switch" disabled lay-text="是|否"
           lay-filter="statebasic" {{ d.state==1?'checked':'' }}>
    {{#  } }}
</script>
<script type="text/html" id="isValidatemaintain">
    {{#  if(d.change== 'yes'){}}
    {{#  if(d.type== 'textarea'||d.type== 'radio'||d.type=='checkbox'||d.type=='selects'){}}
    <input type="checkbox" name="isValidate" value="{{d.id}}" lay-skin="switch" lay-text="是|否" disabled
           lay-filter="isValidatebasic" {{ d.isValidate=="yes"?'checked':'' }}>
    {{#  } else {}}
    <input type="checkbox" name="isValidate" value="{{d.id}}" lay-skin="switch" lay-text="是|否"
           lay-filter="isValidatebasic" {{ d.isValidate=="yes"?'checked':'' }}>
    {{#  } }}
    {{#  } else {}}
    <input type="checkbox" name="isValidate" value="{{d.id}}" lay-skin="switch" disabled lay-text="是|否"
           lay-filter="isValidatebasic" {{ d.isValidate=="yes"?'checked':'' }}>
    {{#  } }}
</script>
<script type="text/html" id="stateextend">
    {{#  if(d.change== 'yes'){}}
    <input type="checkbox" name="state" value="{{d.id}}" lay-skin="switch" lay-text="是|否" lay-filter="statebasic" {{
           d.state==1?'checked':'' }}>
    {{#  } else {}}
    <input type="checkbox" name="state" value="{{d.id}}" lay-skin="switch" disabled lay-text="是|否"
           lay-filter="statebasic" {{ d.state==1?'checked':'' }}>
    {{#  } }}
</script>
<script type="text/html" id="isValidateextend">
    {{#  if(d.change== 'yes'){}}
    {{#  if(d.type== 'textarea'||d.type== 'radio'||d.type=='checkbox'||d.type=='selects'){}}
    <input type="checkbox" name="isValidate" value="{{d.id}}" lay-skin="switch" lay-text="是|否" disabled
           lay-filter="isValidatebasic" {{ d.isValidate=="yes"?'checked':'' }}>
    {{#  } else {}}
    <input type="checkbox" name="isValidate" value="{{d.id}}" lay-skin="switch" lay-text="是|否"
           lay-filter="isValidatebasic" {{ d.isValidate=="yes"?'checked':'' }}>
    {{#  } }}
    {{#  } else {}}
    <input type="checkbox" name="isValidate" value="{{d.id}}" lay-skin="switch" disabled lay-text="是|否"
           lay-filter="isValidatebasic" {{ d.isValidate=="yes"?'checked':'' }}>
    {{#  } }}
</script>
<script type="text/html" id="headbasic">
    {{#  if(d.head === '1'){ }}
    <span style="color: #f51d02;">{{ '显示' }}</span>
    {{#  } else { }}
    {{ '隐藏' }}
    {{#  } }}
</script>
<script type="text/html" id="headdetailed">
    {{#  if(d.head === '1'){ }}
    <span style="color: #f51d02;">{{ '显示' }}</span>
    {{#  } else { }}
    {{ '隐藏' }}
    {{#  } }}
</script>
<script type="text/html" id="headmaintain">
    {{#  if(d.head === '1'){ }}
    <span style="color: #f51d02;">{{ '显示' }}</span>
    {{#  } else { }}
    {{ '隐藏' }}
    {{#  } }}
</script>
<script type="text/html" id="headextend">
    {{#  if(d.head === '1'){ }}
    <span style="color: #f51d02;">{{ '显示' }}</span>
    {{#  } else { }}
    {{ '隐藏' }}
    {{#  } }}
</script>
<script src="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/layui.all.js"></script>
<script src="<%=request.getContextPath()%>/huazhi/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['table', 'attribute', 'form', 'layer'], function () {
        var $ = layui.jquery,
            table = layui.table,
            form = layui.form,
            layer = layui.layer;


        //监听基本信息表格上面的工具蓝
        table.on('toolbar(basicList)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id)
                , data = checkStatus.data; //获取选中的数据
            switch (obj.event) {
                case 'add':
                    addbasic(data);
                    break;
            }
        });

        function addbasic(data) {
            var clocess = "1";
            var index = layer.open({
                title: "添加",
                type: 2,
                content: '<%=request.getContextPath()%>/rest/getRoute?type=system&url=attribute_add',
                area: ['90%', '91%'],
                maxmin: true,
                //是否显示右上角关闭图标，默认为1，显示
                anim: 4,
                shade: 0.6,
                skin: 'layui-layer-molv',
                resize: true,
                success: function (layero, index) {  //当你需要在层创建完毕时即执行一些语句，可以通过该回调 想相当于吧值转到子界面
                    var body = layer.getChildFrame('body', index);//建立父子联系  //当你试图在当前页获取iframe页的DOM元素时，你可以用此方法。
                    var iframe = window['layui-layer-iframe'+index];
                    //调用子页面的全局函数
                    iframe.child("1")
                },
                cancel: function (index, layero) {
                    layer.close(index)
                    clocess = "2"
                    return false;
                },
                end: function () {
                    if (clocess == "2") {

                    } else {
                        table.reload('basic')
                    }
                    return false;
                }
            });
            $('.layui-layer-setwin .layui-layer-max').css("display", "none")
            $('.layui-layer-setwin .layui-layer-min').css("display", "none")
        }


        //监听详细信息表格上面的工具
        table.on('toolbar(detailedList)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id)
                , data = checkStatus.data; //获取选中的数据
            switch (obj.event) {
                case 'add':
                    adddetailed(data);
                    break;
            }
        });

        function adddetailed(data) {

            var clocess = "1";
            var index = layer.open({
                title: "添加",
                type: 2,
                content: '<%=request.getContextPath()%>/rest/getRoute?type=system&url=attribute_add',
                area: ['90%', '91%'],
                maxmin: true,
                //是否显示右上角关闭图标，默认为1，显示
                anim: 4,
                shade: 0.6,
                skin: 'layui-layer-molv',
                resize: true,
                success: function (layero, index) {  //当你需要在层创建完毕时即执行一些语句，可以通过该回调 想相当于吧值转到子界面
                    var iframe = window['layui-layer-iframe'+index];
                    //调用子页面的全局函数
                    iframe.child("2")
                },
                cancel: function (index, layero) {
                    layer.close(index)
                    clocess = "2"
                    return false;
                },
                end: function () {
                    if (clocess == "2") {

                    } else {
                        table.reload('detailed')
                    }
                    return false;
                }
            });

            $('.layui-layer-setwin .layui-layer-max').css("display", "none")
            $('.layui-layer-setwin .layui-layer-min').css("display", "none")

        }

        //监听详细信息表格上面的工具
        table.on('toolbar(maintainList)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id)
                , data = checkStatus.data; //获取选中的数据
            switch (obj.event) {
                case 'add':
                    adddmaintain(data);
                    break;
            }
        });

        function adddmaintain(data) {
            var clocess = "1";
            var index = layer.open({
                title: "添加",
                type: 2,
                content: '<%=request.getContextPath()%>/rest/getRoute?type=system&url=attribute_add',
                area: ['90%', '91%'],
                maxmin: true,
                //是否显示右上角关闭图标，默认为1，显示
                anim: 4,
                shade: 0.6,
                skin: 'layui-layer-molv',
                resize: true,
                success: function (layero, index) {  //当你需要在层创建完毕时即执行一些语句，可以通过该回调 想相当于吧值转到子界面
                    var iframe = window['layui-layer-iframe'+index];
                    //调用子页面的全局函数
                    iframe.child("3")
                },
                cancel: function (index, layero) {
                    layer.close(index)
                    clocess = "2"
                    return false;
                },
                end: function () {
                    if (clocess == "2") {

                    } else {
                        table.reload('maintain')
                    }
                    return false;
                }
            });

            $('.layui-layer-setwin .layui-layer-max').css("display", "none")
            $('.layui-layer-setwin .layui-layer-min').css("display", "none")

        }


        //监听详细信息表格上面的工具
        table.on('toolbar(extendList)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id)
                , data = checkStatus.data; //获取选中的数据
            switch (obj.event) {
                case 'add':
                    addextend(data);
                    break;
            }
        });

        function addextend(data) {
            var clocess = "1";
            var index = layer.open({
                title: "添加",
                type: 2,
                content: '<%=request.getContextPath()%>/rest/getRoute?type=system&url=attribute_add',
                area: ['90%', '91%'],
                maxmin: true,
                //是否显示右上角关闭图标，默认为1，显示
                anim: 4,
                shade: 0.6,
                skin: 'layui-layer-molv',
                resize: true,
                success: function (layero, index) {  //当你需要在层创建完毕时即执行一些语句，可以通过该回调 想相当于吧值转到子界面
                    var iframe = window['layui-layer-iframe'+index];
                    //调用子页面的全局函数
                    iframe.child("5")
                },
                cancel: function (index, layero) {
                    layer.close(index)
                    clocess = "2"
                    return false;
                },
                end: function () {
                    if (clocess == "2") {

                    } else {
                        table.reload('extend')
                    }
                    return false;
                }
            });
            $('.layui-layer-setwin .layui-layer-max').css("display", "none")
            $('.layui-layer-setwin .layui-layer-min').css("display", "none")
        }

        //监听操作
        form.on('switch(statebasic)', function (obj) {
            var flag = "";
            var id = this.value;
            if (true == obj.elem.checked) {
                flag = '1';
            } else {
                flag = '0';
            }
            $.ajax({
                type: "post",
                url: "<%=request.getContextPath()%>/rest/system/updateStructureState",
                data: "id=" + id + "&state=" + flag,
                dataType: "json",
                async: false,
                success: function (data) {
                }
            })
        });

        //监听操作
        form.on('switch(isValidatebasic)', function (obj) {
            var flag = "";
            var id = this.value;
            if (true == obj.elem.checked) {
                flag = 'yes';
            } else {
                flag = 'no';
            }
            $.ajax({
                type: "post",
                url: "<%=request.getContextPath()%>/rest/system/updateStructureIsvalidate",
                data: "id=" + id + "&isValidate=" + flag,
                dataType: "json",
                async: false,
                success: function (data) {
                }
            })
        });

        //监听操作
        form.on('switch(statedetailed)', function (obj) {
            var flag = "";
            var id = this.value;
            if (true == obj.elem.checked) {
                flag = '1';
            } else {
                flag = '0';
            }
            $.ajax({
                type: "post",
                url: "<%=request.getContextPath()%>/rest/system/updateStructureState",
                data: "id=" + id + "&state=" + flag,
                dataType: "json",
                async: false,
                success: function (data) {
                }
            })
        });

        //监听操作
        form.on('switch(isValidatedetailed)', function (obj) {
            var flag = "";
            var id = this.value;
            if (true == obj.elem.checked) {
                flag = 'yes';
            } else {
                flag = 'no';
            }
            $.ajax({
                type: "post",
                url: "<%=request.getContextPath()%>/rest/system/updateStructureIsvalidate",
                data: "id=" + id + "&isValidate=" + flag,
                dataType: "json",
                async: false,
                success: function (data) {
                }
            })
        });

        //监听操作
        form.on('switch(statemaintain)', function (obj) {
            var flag = "";
            var id = this.value;
            if (true == obj.elem.checked) {
                flag = '1';
            } else {
                flag = '0';
            }
            $.ajax({
                type: "post",
                url: "<%=request.getContextPath()%>/rest/system/updateStructureState",
                data: "id=" + id + "&state=" + flag,
                dataType: "json",
                async: false,
                success: function (data) {
                }
            })
        });

        //监听操作
        form.on('switch(isValidatemaintain)', function (obj) {
            var flag = "";
            var id = this.value;
            if (true == obj.elem.checked) {
                flag = 'yes';
            } else {
                flag = 'no';
            }
            $.ajax({
                type: "post",
                url: "<%=request.getContextPath()%>/rest/system/updateStructureIsvalidate",
                data: "id=" + id + "&isValidate=" + flag,
                dataType: "json",
                async: false,
                success: function (data) {
                }
            })
        });

        //监听操作
        form.on('switch(stateextend)', function (obj) {
            var flag = "";
            var id = this.value;
            if (true == obj.elem.checked) {
                flag = '1';
            } else {
                flag = '0';
            }
            $.ajax({
                type: "post",
                url: "<%=request.getContextPath()%>/rest/system/updateStructureState",
                data: "id=" + id + "&state=" + flag,
                dataType: "json",
                async: false,
                success: function (data) {
                }
            })
        });

        //监听操作
        form.on('switch(isValidateextend)', function (obj) {
            var flag = "";
            var id = this.value;
            if (true == obj.elem.checked) {
                flag = 'yes';
            } else {
                flag = 'no';
            }
            $.ajax({
                type: "post",
                url: "<%=request.getContextPath()%>/rest/system/updateStructureIsvalidate",
                data: "id=" + id + "&isValidate=" + flag,
                dataType: "json",
                async: false,
                success: function (data) {
                }
            })
        });


    });
</script>
</body>
</html>
